package com.chinatelecom.telecollege.sellerrewarding.service;

import com.chinatelecom.telecollege.sellerrewarding.Entity.sellorder;
import com.chinatelecom.telecollege.sellerrewarding.repository.sellorderRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by lenovo on 2017/6/21.
 */
@Service
public class sellorderService {
    @Autowired
    private sellorderRepo sellorderRepo;

    @Transactional
    public List<sellorder> findAll() {
        return sellorderRepo.findAll();
    }
    public sellorder findByid(int id) {
        return sellorderRepo.findOne(id);
    }
    public List<sellorder> findByseller(String phoneseller) {
        return sellorderRepo.findByphoneseller(phoneseller);
    }
    public void save(String phone_seller, String date, String name, String phone, int id_product) {
        sellorder sellorder = new sellorder();
        sellorder.setPhoneseller(phone_seller);
        sellorder.setDate(date);
        sellorder.setName(name);
        sellorder.setPhone(phone);
        sellorder.setIdproduct(id_product);
        sellorderRepo.save(sellorder);
    }
}
